<?php
$this->breadcrumbs=array(
	'Categories'=>array('index'),
	'Create',
);

$this->menu=array(
	array('label'=>'List Category', 'url'=>array('index')),
	array('label'=>'Manage Category', 'url'=>array('admin')),
);
?>
<script type="text/javascript">
<!--
	$(function(){
		//两级连动
		$("#Category_cate_type").change(function(){
//			alert($(this).val());
			$.getJSON("<?php echo $this->createUrl('children');?>",{'cid':$(this).val()},function(msg){
//				alert(msg);
//		var msg = {"7":"\u76f8\u518c","8":"|\uff0d\u6536\u85cf\u7f8e\u56fe","9":"|\uff0d\u592a\u6e56\u7f8e\u666f","11":"|\uff0d\u6f2b\u753b"}		
//				$("#Category_cate_pid").html(msg);
//				dd = "";
				
				var pid = document.getElementById("Category_cate_pid");

				//清除所有已有选项
				while(pid.childNodes.length>0){
					pid.removeChild(pid.childNodes[0]);
				}
				$.each(msg,function(k,v){
//					dd += (k+v);

					
					var option = new Option(v,k);
					pid.options.add(option);
				});
//				alert(dd);
			});
			
		});

//		$("#Category_cate_pid").change(function(){
//			alert($(this).val());
//		});

//		$("#cate_submit").button();
		$(".itemsubmit").button();

		//增加分类
		$("#cate_submit").click(function(){
//			alert($("#Category_cate_name").val()+$("#Category_cate_pid").val()+$("#Category_cate_type").val()+$("#Category_cate_order").val()+$(document.getElementsByTagName('iframe')[0].contentWindow.document.body).html());
			$.post('<?php echo $this->createUrl("create");?>',{
				'cate_name':$("#Category_cate_name").val(),
				'cate_pid':$("#Category_cate_pid").val(),
				'cate_type':$("#Category_cate_type").val(),
				'cate_order':$("#Category_cate_order").val(),
				'cate_des':$("#Category_cate_des").val(),
				'cate_recommend':$("#Category_cate_recommend").val(),
				'cate_contype':$("#Category_cate_contype").val(),
				'cate_link':$("#Category_cate_link").val(),
				'self':1
			},function(msg){
				if(msg != "false"){
					$("#category-list-items").html(msg);
				}else{
					alert(msg);
				}
				
			});
		});

 	});



//-->
</script>
<div class="column1 colborder">
<div class="box">
	<?php $this->beginWidget('zii.widgets.CPortlet', array('title'=>'Create Category',	));?>
		<div class="box-content">
			<?php echo $this->renderPartial('/category/_form', array('model'=>$model)); ?>
		</div>
	<?php $this->endWidget();?>	
</div>
</div>

<div class="column2" id="category-list-items">
	<?php echo $this->renderPartial('/category/items', array('dataProvider'=>$dataProvider)); ?>
</div>
